package com.luoran.bartalks.service.impl;

import java.util.List;

import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.luoran.bartalks.action.vo.PackingListMaterielOfExportVo;
import com.luoran.bartalks.action.vo.ScanMaterielResultVo;
import com.luoran.bartalks.dao.IBtPackingListMaterielDao;
import com.luoran.bartalks.dao.IBtScanMaterielResultVoDao;
import com.luoran.bartalks.entity.BaseInfo;
import com.luoran.bartalks.entity.biz.BtMateriel;
import com.luoran.bartalks.entity.biz.BtPackingListMateriel;
import com.luoran.bartalks.service.IBtPackingListMaterielService;

@Service
public class BtPackingListMaterielService implements IBtPackingListMaterielService {

    @Autowired
    private IBtPackingListMaterielDao packingListMaterielDao;

    @Autowired
    private IBtScanMaterielResultVoDao scanMaterielResultVoDao;

    // 添加箱单物料
    @Override
    public String addPackingListMateriel(BtPackingListMateriel packingListMateriel) {
        packingListMaterielDao.insertTemplate(packingListMateriel);
        return packingListMateriel.getId();// 返回主键ID
    }

    @Override
    public PageQuery<? extends BaseInfo> getQueryList(PageQuery<? extends BaseInfo> pageQuery) {
        packingListMaterielDao.queryPage(pageQuery);
        return pageQuery;
    }

    // 删除
    @Override
    public int deletePackingListMateriel(String id) {

        return packingListMaterielDao.deleteById(id);
    }

    @Override
    public BtPackingListMateriel getItem(String id) {
        return packingListMaterielDao.single(id);
    }

    // 通过箱单id 查询物料
    @Override
    public List<BtPackingListMateriel> getMaterielsByPackingListId(String packingListId) {

        return packingListMaterielDao.getMaterielsByPackingListId(packingListId);
    }

    // 物料编码查询箱单,校验当前物料是否被引用
    @Override
    public List<BtPackingListMateriel> hasMateriel(String materielCode, String companyId) {
        return packingListMaterielDao.hasMateriel(materielCode, companyId);
    }

    // 通过箱单ID 查询容器
    @Override
    public List<BtPackingListMateriel> getContainerByPackingListId(String packingListId) {
        return packingListMaterielDao.getContainerByPackingListId(packingListId);
    }

    // 根据箱单物料关系id和计划id 校验当前扫描物料是否合法
    @Override
    public BtPackingListMateriel getItemByPackingListMaterielIdAndPlanId(String packingListMaterielId, String planId) {

        return packingListMaterielDao.getItemByPackingListMaterielIdAndPlanId(packingListMaterielId, planId);
    }

    @Override
    public BtPackingListMateriel getItemByPackingListMaterielIdAndCompanyId(String packingListMaterielId,
            String companyId) {
        return packingListMaterielDao.getItemByPackingListMaterielIdAndCompanyId(packingListMaterielId, companyId);
    }

    @Override
    public ScanMaterielResultVo getScanMaterielResult(String packingListMaterielId, String companyId) {
        return scanMaterielResultVoDao.getScanMaterielResult(packingListMaterielId, companyId);
    }

    @Override
    public BtMateriel getMaterielByPackingListMaterielId(String packingListMaterielId, String companyId) {

        return packingListMaterielDao.getMaterielByPackingListMaterielId(packingListMaterielId, companyId);
    }

	@Override
	public BtPackingListMateriel getItemByMaterielQrcodeAndCompanyId(String qrcode, String companyId) {
		return packingListMaterielDao.getItemByMaterielQrcodeAndCompanyId(qrcode, companyId);
	}

	@Override
	public List<String> checkMaterielQrcodeOnlyByCompanyId(String companyId) {
		return packingListMaterielDao.checkMaterielQrcodeOnlyByCompanyId(companyId);
	}

	@Override
	public List<PackingListMaterielOfExportVo> getMaterielsByPackingListIdOfExport(String packingListId) {
		return packingListMaterielDao.getMaterielsByPackingListIdOfExport(packingListId);
	}

	@Override
	public List<BtPackingListMateriel> checkMaterielOfAppByCompanyId(String companyId) {
		return packingListMaterielDao.checkMaterielOfAppByCompanyId(companyId);
	}

	@Override
	public List<BtPackingListMateriel> getMaterielOfApp(String companyId, String userId) {
		return packingListMaterielDao.getMaterielOfApp(companyId, userId);
	}

	@Override
	public BtPackingListMateriel getByMaterielQrcodeAndCompanyId(String materielQrcode, String companyId) {
		return packingListMaterielDao.getByMaterielQrcodeAndCompanyId(materielQrcode, companyId);
	}



	
}
